import { dateUtils } from 'my-ts-core';
import { useState } from 'react';

import { useTimer } from '@/shared/hooks/general-hook';

function Clock() {
  const [date, setDate] = useState<Date>(dateUtils.getCurrentDate());

  useTimer(callback);

  function callback(d: Date): void {
    setDate(d);
  }

  return <div>{date.toLocaleTimeString()}</div>;
}

export default Clock;
